package com.leyou.order.service.controller;

import com.leyou.common.bean.PageResult;
import com.leyou.common.bean.Result;
import com.leyou.order.inter.dto.WebOrderPageDTO;
import com.leyou.order.inter.pojo.Order;
import com.leyou.order.inter.pojo.OrderDetail;
import com.leyou.order.service.service.OrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author zqq
 * @ClassName OrderWebController
 * @Description
 * @date 2020/4/8-14:10
 */
@Api(value = "OrderWebController",description = "后台订单服务接口")
@RestController
@RequestMapping("web")
public class OrderWebController {

    @Autowired
    private OrderService orderService;

    @GetMapping("query/order/detail/{id}")
    @ApiOperation(value = "查询订单详情", notes = "查询订单详情")
    public Result<List<OrderDetail>> queryOrderDetail(@ApiParam(name = "id",value = "订单id",required = true) @PathVariable("id") Long id) {
        return this.orderService.queryDetailByOrderId(id);
    }

    @PostMapping("order/page")
    @ApiOperation(value = "分页查询订单", notes = "分页查询订单")
    public Result<PageResult<Order>> queryOrderByDto(@RequestBody WebOrderPageDTO dto) {
        return this.orderService.queryOrderByDto(dto);
    }

    @DeleteMapping("delete/{id}")
    @ApiOperation(value = "删除订单", notes = "删除订单")
    public Result deleteOrder(@ApiParam(name = "id",value = "订单id",required = true) @PathVariable("id") Long id) {
        return this.orderService.deleteOrder(id.toString());
    }


}
